package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 09-请求对象获取请求行
 */
@WebServlet("/demo13")
public class Demo13Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //getMethod : 获取请求方式
        System.out.println("请求方式 = " + request.getMethod());
        //getContextPath : 获取项目访问路径
        System.out.println("项目访问路径 = " + request.getContextPath());
        //getServletPath : 获取Servlet访问路径
        System.out.println("Servlet访问路径 = " + request.getServletPath());
        //getRemoteAddr : 获取客户端地址
        System.out.println("客户端地址 : " + request.getRemoteAddr());
        //getLocalAddr : 获取服务器地址
        System.out.println("服务器地址 : " + request.getLocalAddr());
        //getRequestURL : 找设备 -> 找tomcat -> 找项目 -> 找资源
        System.out.println("统一资源定位符 : " + request.getRequestURL());
        //getRequestURI : 找项目 -> 找资源
        System.out.println("统一资源标识符 : " + request.getRequestURI());
        //getQueryString(了解) : 获取URL后的参数
        System.out.println("QueryString : " + request.getQueryString());


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
